-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't update dynamiccssrules on panning, add chromium percentage missing redraw workaround #140
base: main
Are you sure you want to change the base?
Conversation
const previousMaxDisplayedSize = this.getPreviousMaxDisplayedSize(); | ||
// in case of bad or unset values NaN or Infinity, this condition is skipped and the function behaves as if zoom changed | ||
if ( | ||
Math.abs(previousMaxDisplayedSize - maxDisplayedSize) / previousMaxDisplayedSize < |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
divide by zero
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in case of bad or unset values NaN or Infinity, this condition is skipped and the function behaves as if zoom changed
//Workaround chromium (tested on edge and google-chrome 131) doesn't | ||
//redraw things with percentages on viewbox changes but it should, | ||
//force it. Firefox does correctly redraw, but we force for everyone to | ||
//have the same behavior everywhere and detect problems more easily. | ||
//we can't use innerHtml+='' on the <style> tags because values set | ||
//with setProperty(key, value) in updateSvgCssDisplayValue are not | ||
//reflected in the html text so the innerHTML trick has the effect of | ||
//resetting them. So instead of doing it on the svg, we do it on all | ||
//its children that are not style elements. This won't work if there | ||
//are deeply nested style elements that need dynamic css rules but in | ||
//practice only the root style element hasdynamic rules so it's ok. | ||
//remove this when chromium fixes their bug if this workaround causes | ||
//problem, we can find a better way to force a redraw that doesnt | ||
//change the elements in the dom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//Workaround chromium (tested on edge and google-chrome 131) doesn't | |
//redraw things with percentages on viewbox changes but it should, | |
//force it. Firefox does correctly redraw, but we force for everyone to | |
//have the same behavior everywhere and detect problems more easily. | |
//we can't use innerHtml+='' on the <style> tags because values set | |
//with setProperty(key, value) in updateSvgCssDisplayValue are not | |
//reflected in the html text so the innerHTML trick has the effect of | |
//resetting them. So instead of doing it on the svg, we do it on all | |
//its children that are not style elements. This won't work if there | |
//are deeply nested style elements that need dynamic css rules but in | |
//practice only the root style element hasdynamic rules so it's ok. | |
//remove this when chromium fixes their bug if this workaround causes | |
//problem, we can find a better way to force a redraw that doesnt | |
//change the elements in the dom | |
//Workaround chromium (tested on edge and google-chrome 131) doesn't | |
//redraw things with percentages on viewbox changes but it should, | |
//so we force it. Firefox correctly redraws, but we force it for everyone to | |
//have the same behavior everywhere and detect problems more easily. | |
//We can't use innerHtml+='' on the <style> tags because values set | |
//with setProperty(key, value) in updateSvgCssDisplayValue are not | |
//reflected in the html text so the innerHTML trick has the effect of | |
//resetting them. So instead of doing it on the svg, we do it on all | |
//its children that are not style elements. This won't work if there | |
//are deeply nested style elements that need dynamic css rules but in | |
//practice only the root style element has dynamic rules so it's ok. | |
//Remove this when chromium fixes their bug if this workaround causes | |
//problem, we can find a better way to force a redraw that doesnt | |
//change the elements in the dom |
Signed-off-by: HARPER Jon <[email protected]>
This allows to see the effect of the workarounds for the css containing percent in the demo. And it's generally useful to have this kind of css when enabling level of detail Signed-off-by: HARPER Jon <[email protected]>
Signed-off-by: HARPER Jon <[email protected]>
Signed-off-by: HARPER Jon <[email protected]>
912cebd
to
52cdd79
Compare
Quality Gate passedIssues Measures |
Please check if the PR fulfills these requirements
Does this PR already have an issue describing the problem?
NO
What kind of change does this PR introduce?
feature/bugfix
What is the current behavior?
css rules are updated when the viewbox changes, even for translations. But we only use the zoom level in rules
Also, chromium doesn't update the rendering when of percents (stroke-width), so add a workaround to force redraw
when the zoom changes by 1 percent
What is the new behavior (if this is a feature change)?
no update of rules during translations. Chromium redraw on zoom workaround (enabled all the time for consistency)
Does this PR introduce a breaking change or deprecate an API?
Other information:
we could split this PR in 2. We could enable the workaround only if we detect dynamic rules with percentages